<?php

namespace app\common\model\Member;
use think\Db;

use app\common\model\Base;

class FollowBlacklist extends Base
{
    protected $name = 'member_follow_blacklist';

    public function getFollowBlackList($class_type, $type, $text)
    {
        $where = [['mfb.type', '=', $class_type], ['mfb.status', '=', 1]];
        $or = [];
        if ($type && $type == 1) {
            $where[] = ['', 'exp', Db::raw('FROM_UNIXTIME(`mfb`.`update_time`,\'%Y-%m-%d\') = \'' . date('Y-m-d') . '\'')];
        }
        if ($type && $type == 'id' && !empty($text)) {
            $or = ['mfb.member_id' => $text, 'mfb.been_member_id' => $text];
        }
        return $this->alias('mfb')->where($where)->where(function ($query) use ($or) {$query->whereOr($or);})
        ->join('member m1', 'm1.id = mfb.member_id', 'LEFT')
        ->join('member m2', 'm2.id = mfb.been_member_id', 'LEFT')
        ->field('mfb.*, m1.id member_id, m1.avatar member_avatar, m1.nickname member_nickname, m2.id been_id, m2.avatar been_avatar, m2.nickname been_nickname')
        ->paginate();
    }
}
